/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package samoloty.view;

import Utils.ScreensOrder;
import java.awt.Font;
import java.awt.Point;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JTextArea;

/**
 *
 * @author borysfan
 */
class MyTextArea extends JTextArea {

    public MyTextArea(){
        super();
        initTextArea();
    }

    public MyTextArea(int rows,int columns){
        super(rows,columns);
        initTextArea();
    }

    private void initTextArea(){
        Font f = new Font("monospaced",Font.PLAIN,14 );
        setFont(f);
        setBackground(MyColors.getBlack());
        setForeground(MyColors.getWhite());
        setWrapStyleWord(true);
        MyCaret c = new MyCaret();
        setCaret(c);
        addKeyListener(new KeyBoardListener());
        
    }

    public void setPosition(Point p){
        this.setBounds(p.x, p.y, (int)getPreferredSize().getWidth(),(int)getPreferredSize().getHeight());
    }

     private class KeyBoardListener implements KeyListener{

        public void keyTyped(KeyEvent e) {

        }

        public void keyPressed(KeyEvent e) {
            int code = e.getKeyCode();

            if(code == KeyEvent.VK_F1){
                ScreensOrder order = ScreensOrder.getInstance();
                order.prevScreen();
            }else if(code == KeyEvent.VK_F2){
                ScreensOrder order = ScreensOrder.getInstance();
                order.nextScreen();
            }
        }

        public void keyReleased(KeyEvent e) {

        }

    }
}
